import { defineStore } from 'pinia'
import storage from '@/utils/storage'

export const useDefaultStore = defineStore('default', {
  state() {
    return {
      navList: [], // 首页快捷导航
      cartNum: storage.getItem('cartNum') || 0,
      logoImg: storage.getItem('logoImg') || import('@/assets/logoko.png'),
      siteName: storage.getItem('siteName') || 'ego-mall',
      hotWordsList: storage.getItem('hotWordsList'),
      category: JSON.parse(<string>localStorage.getItem('category'))
    }
  },
  actions: {
    SET_CATEGORY: (data) => {
      console.log('category',this.category);
      this.category = data
    },
    SET_NAVLIST: (data) => {
      this.navList = data
    },
    SET_CARTNUM: (data) => {
      this.cartNum = data
    },
    SET_HOTWORDS: (data) => {
      this.hotWordsList = data
    },
    SET_LOGOIMG: (data) => {
      this.logoImg = data
    },
    SET_SITENAME: (data) => {
      this.siteName = data
    }
  }
})
